package com.uh.checking.config;

import com.uh.checking.proc.JarCheckingUtils;

import java.util.Arrays;

import static com.uh.checking.config.JarCheckingConstants.SUB_JAR_STEPS;

public class SubJarConfig {
    private FileFilterCfg includeFilter;
    private String beginStep; //开始步骤
    private String endStep; //结束步骤

    private String[] deleteFiles; //要删除的文件和目录

    private String[] manifestIncludeKeys;

    private String[] replace; //文件名中要替换相应的字符串[from , to]

    private String[] steps = null;

    public FileFilterCfg getIncludeFilter() {
        return includeFilter;
    }

    public void setIncludeFilter(FileFilterCfg includeFilter) {
        this.includeFilter = includeFilter;
    }

    public String getBeginStep() {
        return beginStep;
    }

    public void setBeginStep(String beginStep) {
        this.beginStep = beginStep;
    }

    public String getEndStep() {
        return endStep;
    }

    public void setEndStep(String endStep) {
        this.endStep = endStep;
    }

    public String[] getDeleteFiles() {
        return deleteFiles;
    }

    public void setDeleteFiles(String[] deleteFiles) {
        this.deleteFiles = deleteFiles;
    }

    public String[] getManifestIncludeKeys() {
        return manifestIncludeKeys;
    }

    public void setManifestIncludeKeys(String[] manifestIncludeKeys) {
        this.manifestIncludeKeys = manifestIncludeKeys;
    }

    public String[] getReplace() {
        return replace;
    }

    public void setReplace(String[] replace) {
        this.replace = replace;
    }

    public String[] getSteps() {
        if(steps == null) {
            steps = JarCheckingUtils.trimSteps(SUB_JAR_STEPS, this.beginStep, this.endStep);
        }
        return steps;
    }


    @Override
    public String toString() {
        return "SubJarConfig{" +
                "includeFilter=" + includeFilter +
                ", beginStep='" + beginStep + '\'' +
                ", endStep='" + endStep + '\'' +
                ", deleteFiles=" + Arrays.toString(deleteFiles) +
                ", manifestIncludeKeys=" + Arrays.toString(manifestIncludeKeys) +
                ", replace='" + replace + '\'' +
                "}\n";
    }
}
